import java.util.*;
import java.util.ArrayList;

public class Test {


    public static void main18(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String a = in.next();
            String b = in.next();
            String ret = add(a,b);
            System.out.println(ret);
        }
    }
    //字符串相加
    //输入：1101 1100
    //输出：11001
    public static String add(String a,String b) {
        StringBuilder ret = new StringBuilder();

        int lenA = a.length();
        int lenB = b.length();

        StringBuilder reverseA = new StringBuilder(a).reverse();
        StringBuilder reverseB = new StringBuilder(b).reverse();

        int max = Math.max(lenA,lenB);

        boolean over = false;

        for(int i = 0; i<max; i++){

            char A = i >= lenA ? '0' : reverseA.charAt(i);
            char B = i >= lenB ? '0' : reverseB.charAt(i);
            //110
            //1101
            if (A == '1' && B == '1') {
                if(over) {
                    ret.append('1');
                }else{
                    ret.append('0');
                }
                over = true;
            }else if (A == '0' && B == '0') {
                if(over) {
                    ret.append('1');
                }else{
                    ret.append('0');
                }
                over = false;
            }else {
                if(over){
                    ret.append('0');
                    over = true;
                }else{
                    ret.append('1');
                }
            }
        }
        if(over){
            ret.append('1');
        }
        return ret.reverse().toString();
    }

    //大写转小写
    public static String func(String a,String b) {
        StringBuilder ret = new StringBuilder();
        for(int i = 0; i<a.length(); i++) {
            if(!b.contains(a.charAt(i)+"")){
                ret.append(a.charAt(i));
            }
        }
        return ret.toString();
    }

//    移除元素
//    输入：nums = [3,2,2,3], val = 3
//    输出：2, nums = [2,2,_,_]
    public static int removeElement(int[] nums, int val) {
        int ret = 0;
        for(int i = 0; i<nums.length; i++) {
            if(nums[i] == val) {
                nums[ret] = nums[i];
                ret++;
            }
        }
        return ret;
    }

    public static int removeElement1(int[] nums, int val) {
        int[] tmp = new int[nums.length];
        int left = 0;
        int repeat = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                tmp[left] = nums[i];
                left++;
            }else {
                repeat++;
            }
        }
        return repeat;
    }

    public static void main19(String[] args) {
        int[] nums = {3,2,2,4,3};
        int[] tmp = new int[nums.length];
        int left = 0;
        int repeat = 0;
        int key = 3;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != key) {
                tmp[left] = nums[i];
                left++;
            }
        }

        System.out.println(Arrays.toString(tmp));
    }

    //杨辉三角
    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> list = new ArrayList<>();

        List<Integer> n = new ArrayList<>();
        n.add(1);

        list.add(n);

        for (int i = 1; i < numRows; i++) {
            List<Integer> currentRow = new ArrayList<>();

            currentRow.add(1);

            List<Integer> previousRow = list.get(i-1);
            for (int j = 1; j < i; j++) {
                int x = previousRow.get(j) + previousRow.get(j - 1);
                currentRow.add(x);
            }

            currentRow.add(1);

            list.add(currentRow);
        }

        return list;

    }

    public static void main17(String[] args) {
            List<List<Integer>> list = generate(5);
            ListIterator<List<Integer>> it  = list.listIterator();
            while(it.hasNext()) {
                System.out.println(it.next()+" ");

            }





    }

//    删除有序数组中的重复项
    public static int removeDuplicates(int[] nums) {
        int k = 1;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i-1]) {
                nums[k++] = nums[i];
            }
        }
        return k;
    }


    public  static void main16(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        int ret = removeDuplicates(nums);
        System.out.println(ret);



//        System.out.println(Arrays.toString(nums));
    }


    //合并两个有序数组 最优解
    public static void merge1(int[] nums1, int m, int[] nums2, int n) {
        int all = m + n - 1;
        int i = m - 1;
        int j = n - 1;
        while(i>=0 && j>=0) {
            if(nums1[i] >= nums2[j]) {
                nums1[all--] = nums1[i--];
            }else{
                nums1[all--] = nums2[j--];
            }
        }

        while(j>=0){
            nums1[all--] = nums2[j--];
        }

    }

    //合并两个有序数组
    public static void merge2(int[] nums1, int m, int[] nums2, int n) {
        int[] tmp = new int[m+n];
        System.arraycopy(nums1,0,tmp,0,m);
        System.arraycopy(nums2,0,tmp,m,n);
        System.out.println(Arrays.toString(tmp));

    }

    //合并两个有序数组
    public static void merge3(int[] nums1, int m, int[] nums2, int n) {
        int[] tmp = new int[m+n];

        for (int i = 0; i < m; i++) {
            tmp[i] = nums1[i];
        }

        for (int i = 0; i < n; i++) {
            tmp[m+i] = nums2[i];
        }

        nums1 = tmp;

        System.out.println(Arrays.toString(nums1));
    }

    public static void main15(String[] args) {
        int[] array1 = {1,2,3,0,0,0};
        int[] array2 = {4,5,6};
        merge1(array1,3,array2,3);
    }



    public static String func2(String str1,String str2) {
        String ret = "";
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
//            str2.contains(str1)会检查str2里有没有str1的部分
            if (!str2.contains(String.valueOf(ch))) {
                ret += ch;
            }
        }
        return ret;
    }

        public static void main14(String[] args) {
        String str1 = "They are students.";
        String str2= "aeiou";
        System.out.println(func2(str1,str2));

    }

    public static String func1(String str1,String str2) {
//        StringBuffer ret = new StringBuffer();
        String ret = "";
        for (int i = 0; i < str1.length(); i++) {
            char n = str1.charAt(i);
            if (!(str2.contains(String.valueOf(n)))){
//                ret.append(n);
                ret += n;
            }

        }
        return ret.toString();
    }

    public static void main13(String[] args) {
        String str1 = "They are students.";
        String str2= "aeiou";
        System.out.println(func1(str1,str2));

    }
    public static void main12(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int str1 = scanner.nextInt();
        int str2 = scanner.nextInt();

    }

    public static void main11(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input1 = scanner.nextLine();
        String input2 = scanner.nextLine();


        for (int i = 0; i < input1.length(); i++) {

        }
    }

    public static int fib(int n) {
        if (n < 3) {
            return 1;
        }else {
            return fib(n-1) + fib(n-2);
        }

    }
    public static void main5(String[] args) {
        System.out.println(fib(5));
    }


    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String input = scanner.nextLine();
            System.out.println(input.toLowerCase());
        }
    }

    public static void main3(String[] args) {
        MyArraylist myArraylist = new MyArraylist();
        myArraylist.add(0,1);
        myArraylist.add(1,2);
        myArraylist.add(2,3);
        myArraylist.add(3,4);
        myArraylist.remove(2);



        myArraylist.display();
    }

    public static void main2(String[] args) {
        MyArraylist myArraylist = new MyArraylist();
        myArraylist.add(1);
        myArraylist.add(2);
        myArraylist.add(3);
        myArraylist.add(4);
        myArraylist.add(5);
        myArraylist.display();
    }

//    给定一个整数数组 nums，将数组中的元素向右轮转 k 个位置，其中 k 是非负数。
//    输入: nums = [1,2,3,4,5,6,7], k = 3
//    输出: [5,6,7,1,2,3,4]
    public static void rotate(int[] nums, int k) {
        //1.定义一个临时数组
        int[] tmp = new int[nums.length];

        //2.进行遍历，把nums数组的值全部存放在临时数组tmp中
        for (int i = 0; i < nums.length; i++) {
            tmp[i] = nums[i];
        }

        //3.把数组tmp中的值重新赋值回数组nums中，按向后移动k位的位置
        for (int i = 0; i < nums.length; i++) {
            nums[(i+k) % nums.length] = tmp[i];
        }
    }

    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5,6,7};
        rotate(array,3);
        System.out.println(Arrays.toString(array));
    }

}
